<template>
  <a :href="detailUrl">
  <div class="book-card">
    <div class="thumb">
      <img :src="book.image" class="img" 
            mode="aspectFit"
            @click.stop="preview"/>
    </div>
    <div class="detail">
      <div class="row text-primary">
        <div class="left">
          {{book.title}}
        </div>
        <div class="right">
          {{book.rate}}<rate :value='book.rate'></rate>
        </div>
      </div>
      <div class="row text-secondary">
        <div class="left">
          {{book.author}}
        </div>
        <div class="right">
          {{book.count}}阅读
        </div>
      </div>
      <div class="row text-secondary">
        <div class="left">
          {{book.publisher}}
        </div>
        <div class="right">
          <img :src="book.user_info.user_img"/>
          {{book.user_info.nickName}}
        </div>
      </div>
    </div>
  </div>
  </a>
</template>

<script>
import Rate from '@/components/Rate'
export default {
  components:{
    Rate
  },
  props:['book'],
  computed:{
    detailUrl(){
      return '/pages/detail/main?id=' + this.book.id
    }
  },
  methods:{
    preview(){
      wx.previewImage({
        current: this.book.image, // 当前显示图片的http链接
        urls: [this.book.image] // 需要预览的图片http链接列表
      })
    }
  }
}
</script>

<style lang='scss'>
.book-card{
  padding: 5px;
  overflow: hidden;
  margin: 5px 0;
  font-size: 14px;
  .thumb{
    width: 90px;
    height: 90px;
    overflow: hidden;
    margin: 0 auto;
    float: left;
    background-color: #ececec;
    .img{
      max-width: 100%;
      max-height: 100%;
    }
  }
  .detail{
    margin-left: 100px;
    .row{
      line-height: 20px;
      margin-bottom: 3px;
      position: relative;
    }
    .right{
        float: right;
        // margin-top: -20px;
        position: absolute;
        top: 0;
        right: 0;
        img{
          width: 15px;
          height: 15px;
          border-radius: 50%;
          vertical-align: middle;
        }
      }
    .left{
      display: inline-block;
      padding-right: 90px;
    }

  }
}
</style>
